let obj = {
  list: [{
    id: new Date().getTime(),
    title: '写作业',
    isDone: false
  }]
}

function reducer(state = obj, actions) {
  console.log('actions', actions);
  switch (actions.type) {
    case 'addList':
      state.list.push({
        id: new Date().getTime(),
        title: actions.val,
        isDone: false
      });
      break;
    case 'editList':
      state.list.forEach((item) => {
        if (actions.val.id === item.id) {
          item.title = actions.val.title;
        }
      })
      break;
    case 'delList':
      state.list.forEach((item, i) => {
        if (item.id === actions.val) {
          state.list.splice(i, 1)
        }
      })
      break;
    case 'isDone':
      state.list.forEach((item) => {
        if (item.id === actions.val.id) {
          item.isDone = actions.val.isDone;
        }
      })
      break;
    default:

  }

  return JSON.parse(JSON.stringify(state))
}

export default reducer;